package com.ssh.common.log;

import org.apache.log4j.Logger;

public class LogImpl implements Log{ 
	
    private static LogImpl mylog=new  LogImpl();
    public synchronized static LogImpl getInstance(){
    	if(mylog==null)mylog=new  LogImpl();
    	return mylog;
    }
    public boolean isDebugAble(String logName){
    	try{
    		return Logger.getLogger(logName).isDebugEnabled();
    	}catch(Exception e){
    		return false;
    	}
    }
	//debug
	public void debug(String message, String logName) {
		message=opMsg(message);
		Logger.getLogger(logName).debug(message);
	}

	public void debug(String message, Throwable e, String logName) {
		message=opMsg(message);
		Logger.getLogger(logName).debug(message, e);

	}

	//error
	public void error(String message, Throwable e, String logName) {
		e.printStackTrace();
		message=opMsg(message);
		Logger.getLogger(logName).error(message, e);
		
	}

	public void error(String message, String logName) {
		message=opMsg(message);
		Logger.getLogger(logName).error(message);

	}

	//fatal
	public void fatal(String message, Throwable e, String logName) {
		e.printStackTrace();
		message=opMsg(message);
		Logger.getLogger(logName).fatal(message, e);

	}

	public void fatal(String message, String logName) {
		message=opMsg(message);
		Logger.getLogger(logName).fatal(message);

	}

	//info
	public void info(String message, String logName) {
		message=opMsg(message);
		Logger.getLogger(logName).info(message);

	}

	public void warn(String message, String logName) {
		message=opMsg(message);
		Logger.getLogger(logName).warn(message);

	}

	public void warn(String message, Throwable e, String logName) {
		message=opMsg(message);
		Logger.getLogger(logName).warn(message, e);

	}

	public void info(String message, Throwable e, String logName) {
		message=opMsg(message);
		Logger.getLogger(logName).info(message, e);

	}
	public String opMsg(String msg){
		return msg;
	}
}
